package Thread;

import java.lang.reflect.Executable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Dom32 {
    public static void main(String[] args) {
        //Executors 线程池的工厂类
        //创建一个固定数量的线程池
       ExecutorService threadpool= Executors.newFixedThreadPool(4);
        for (int i = 0; i <1000 ; i++) {
            int id=i;
            threadpool.submit(()->{
                System.out.println("hello threadpool "+id+","+Thread.currentThread().getName());
            });
        }

        //线程池 无限大的一个数
         //  Executors.newCachedThreadPool();
        //shutdown 能把线程池的线程全部关闭，但是不能保证线程池内的任务一定全部执行完毕
        threadpool.shutdown();
    }
}
